<link rel="stylesheet" href="__PUBLIC__plugins/spectrum/spectrum.css">
<script src="__PUBLIC__common/js/jquery.2.1.1.min.js"></script>
{js href='__PUBLIC__kindeditor/NKeditor-all-min.js' /}
{js href='__PUBLIC__kindeditor/libs/JDialog/JDialog.min.js' /}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>{$title}</legend>
    </fieldset>
    <form class="layui-form" method="post">
        <input TYPE="hidden" name="id" value="{$info.id|default=0}">
        <div class="layui-form-item">
            <label class="layui-form-label">分类</label>
            <div class="layui-input-5">
                {$cat_str|raw}
            </div>
            <div class="layui-form-mid layui-word-aux red">*必填</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-5" id="box_title">
                <input type="text" name="title" data-required="1" value="{$info.title|default=''}" data-min="1"
                       data-errormsg="标题必须大于1个字符" placeholder="请输入标题" lay-verify="defaul|"
                       class=" layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux red">*必填</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">中文标题</label>
            <div class="layui-input-5">
                <input type="text" name="title_cn" data-required="1" value="{$info.title|default=''}" data-min="1" data-errormsg="标题必须大于1个字符"  placeholder="请输入中文标题" lay-verify="defaul|"
                       class=" layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux red">*必填</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">sku</label>
            <div class="layui-input-5">
                <input type="text" name="sku" data-required="1" value="{$info.sku|default=''}" data-min="1" data-errormsg=""  placeholder="" lay-verify="defaul|"
                       class=" layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux red">*必填</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">关键词</label>
            <div class="layui-input-5" id="box_keywords">
                <input type="text" data-required="0" min="0" max="80" errormsg="" title="关键词" placeholder="请输入关键词"
                       lay-verify="defaul|" class=" layui-input" name="keywords" value="{$info.keywords|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">SEO简介</label>
            <div class="layui-input-5" id="box_description">
                <textarea data-required="0" min="0" max="0" errormsg="" title="SEO简介" placeholder="请输入SEO简介"
                          lay-verify="defaul|" class="description layui-textarea" name="description">{$info.description|default=''}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">市场价</label>
            <div class="layui-input-5">
                <input type="text" name="cost" data-required="1" value="{$info.cost|default=''}"  placeholder="请输入市场价" lay-verify="defaul|"
                       class=" layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux red">*必填</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">单价</label>
            <div class="layui-input-5">
                <input type="text" name="price" data-required="1" value="{$info.price|default=''}"  placeholder="请输入单价" lay-verify="defaul|"
                       class=" layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux red">*必填</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">商品封面</label>
            {$img_str|raw}
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">商品图片</label>
            {$imgs_str|raw}
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">内容</label>
            <div class="layui-input-5 layui-input-7" id="box_content">
                {$c_str|raw}
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
                {if condition="MODULE_NAME eq 'page'"}
                <a href="{:url('category/index')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
                {else /}
                <a href="{:url('index',['catid'=>input('catid')])}"
                   class="layui-btn layui-btn-primary">{:lang('back')}</a>
                {/if}
            </div>
        </div>
    </form>
</div>
<script src='__PUBLIC__plugins/spectrum/spectrum.js'></script>
<script src='__PUBLIC__admin/js/edit.js'></script>
<script src='__PUBLIC__common/js/layui-mz-min.js'></script>
<script>
    var thumb, pic, file;
    var url = "{:url('edit')}";
    layui.use(['form', 'upload', 'layedit', 'laydate', 'jquery'], function () {
        var form = layui.form, upload = layui.upload, layedit = layui.layedit, laydate = layui.laydate,
            $ = layui.jquery;
        layui.selMeltiple($);
        //日期
        form.on('submit(submit)', function (data) {
            $.post(url, data.field, function (res) {
                if (res.code > 0) {
                    layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                        location.href = res.url;
                    });
                } else {
                    layer.msg(res.msg, {time: 1800, icon: 2});
                }
            });
        });
        $('.layui-row').on('click', '.delimg', function () {
            var thisimg = $(this);
            layer.confirm('你确定要删除该图片吗？', function (index) {
                thisimg.parents('.layui-col-md3').remove();
                layer.close(index);
            })
        });
        layui.use("laydate", function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: "#create_time",
                type: "datetime",
                format: "yyyy-MM-dd HH:mm:ss"
            });
        })
    });
</script>